<div data-hook="modeler_factory_form_fields" class="row">
  <div class="col-md-8">
    <%= f.field_container :name, :class => ['form-group'] do %>
      <%= f.label :name, Mes.t(:name) %><br>
      <%= f.text_field :name, :class => 'form-control' %>
    <% end %>
  </div>
  <div class="col-md-4">
    <%= f.field_container :active, :class => ['checkbox'] do %>
      <%= label_tag :active do %>
        <%= f.check_box :active %>
        <%= Mes.t(:active) %>
      <% end %>
    <% end %>
  </div>
  <div class="col-md-12">
    <%= f.field_container :description, :class => ['form-group'] do %>
      <%= f.label :description, Mes.t(:description) %><br>
      <%= f.text_field :description, :class => 'form-control' %>
    <% end %>
  </div>
  <div class="col-md-6">
    <div class="form-group">
      <%= label_tag :new_workflow_step, Mes.t(:new_step_code), class: 'col-sm-4 control-label' %>
      <div class="col-sm-8">
        <%= select_tag :new_workflow_step, options_from_collection_for_select(Mes::StepCode.all, :id, ->(s) { "#{s.name} - #{s.description}" }, nil), class: 'form-control', include_blank: true -%>
      </div>
    </div>
  </div>
  <div class="col-md-8">
    <table class="table" id="listing_workflow_steps">
      <thead>
        <tr>
          <th class="no-border"></th>
          <th><%= Mes.t(:sequence) %></th>
          <th><%= Mes.t(:name) %></th>
          <th><%= Mes.t(:description) %></th>
          <th><%= Mes.t(:active) %></th>
          <th><%= Mes.t(:units_count) %></th>
          <th><%= Mes.t(:lots_count) %></th>
          <th><%= Mes.t(:step_hold_count) %></th>
          <th class="actions">Delete?</th>
        </tr>
      </thead>
      <tbody class="sortable" id="workflow_steps">
      <% workflow.steps.each do |step| -%>
        <%= f.fields_for :steps, step do |g| -%>
        <tr>
          <%= g.hidden_field :sequence %>
          <td class="move-handle"><span class="glyphicon glyphicon-sort handle"></span></td>
          <td><%= step.sequence -%></td>
          <td><%= step.name -%></td>
          <td><%= step.description %></td>
          <td><%= g.check_box :active -%></td>
          <td><%= step.units_count -%></td>
          <td><%= step.lots_count -%></td>
          <td><%= step.step_hold_count -%></td>
          <td class="actions"><%= g.check_box :_destroy -%></td>
          <%= g.hidden_field :step_code_id %>
        </tr>
        <% end -%>
      <% end -%>
      </tbody>
    </table>
  </div>
</div>
